//
//  SMSRequestProvider.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/26.
//  
  

#import "Item1MediaUploadRequestProvider.h"
#import "Item1MediaUploadRequest.h"

//@implementation HomeModel
//@end
//@implementation CommonlyModel
//@end
//@implementation FurnishesModel
//@end
//@implementation WantedModel
//@end

@implementation Item1MediaUploadRequestProvider

/// 图片上传
/// - Parameters:
///   - imageSource: 图片来源:1相册 2:拍照上传
///   - productId: 产品id
///   - peppers: 10:人脸自拍, 11身份证正面
///   - data: 压缩500K以内的图片NSData
///   - cardType: 卡类型 UMID/SSS/TIN/PASSPORT/DRIVINGLICENSE/PRC/POSTAL/Voter/PhilHealth
///   - success: 成功回调
///   - failure: 失败回调
+ (void)requestUploadMediaWithImageSource:(NSString *)imageSource
                                productId:(NSString *)productId
                                  peppers:(NSString *)peppers
                                    image:(UIImage *)image
                                 cardType:(NSString *)cardType
                                  success:(void(^)(NSDictionary *dict))success
                                  failure:(void(^)(YTKRequest *request))failure {
    Item1MediaUploadRequest *request = [Item1MediaUploadRequest new];
    request.bagger = imageSource;
    request.scenery = productId;
    request.peppers = peppers;
    //request.karl = data;
    request.image = image;
    request.monthly = cardType;
#ifdef DEBUG
//    request.bagger = @"1";
//    request.scenery = @"2";
//    request.peppers = @"11";
    //request.karl = [NSData dataNamed:@"idcard.jpg"];
//    request.image = [UIImage imageNamed:@"idcard.jpg"];
//    request.monthly = @"UMID";
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}



@end
